Skip to main content

Node & Service Affinity

After filling in details regarding Access level, Resource Quota, Configurations, Secrets & PVC and Environment Variables, you can also set Node & Service Affinity details. Providing details of Node Affinity and Service Affinity/Anti Affinity is not mandatory. It is completely optional to fill in details for this section.

What are Node Labels?#

Node labels are used by Kubernetes to organize and select nodes based on specific characteristics or attributes. A node label consists of a key, which is a string that identifies the label, and a value, which is an arbitrary string that describes the label. Pods within a cluster are scheduled and deployed to specific nodes based on the node labels using affinity rules.

For instance, if the users select: key= K, value= V, Operator as “=”

This means that pods will be placed on the nodes with the node labels whose “key=K” and “value=V” match each other.

What is Node Affinity?#

Node affinity is a feature in container orchestration platforms such as Kubernetes that allows you to control which nodes (worker machines) your pods (groups of one or more containers) are scheduled on. It allows you to specify rules that influence the scheduling of pods onto nodes based on labels that are attached to the nodes.

Set Node Affinity Required#

According to this Node Affinity rule, the pods will be scheduled on the nodes only when the key and value of their node label meet the specified operator condition including: “=”, “>”,”<”, etc. In case, the key and value do not meet the required operator condition, then pods will not get scheduled on any node.

Here’s how you can set Set Node Affinity Required in the Product.

  • Click “Yes” to Set Node Affinity Required else click “No”.
  • Select Key.
  • Choose Operator.
  • Select Value.
  • Click “Add Row” in order to specify more node affinity rules.

Docs Version Dropdown

Set Node Affinity Preferred#

As per this Node Affinity rule, we set preferences for the scheduling of the pods. Pods will prefer to get scheduled on the nodes where the key and value of their respective node labels meet the specified operator condition including: “=”, “>”,”<”, etc. In case, the key and value in the node label do not meet the desired condition, then too, the pods will get scheduled but on some other nodes.

Here’s how you can set Set Node Affinity Preferred in the Product.

  • Click “Yes” to Set Node Affinity Preferred else click “No”.
  • Select Key.
  • Choose Operator.
  • Select Value.
  • Click “Add Row” in order to specify more node affinity rules.

What is Service Affinity?#

Service affinity is a feature in container orchestration platforms like Kubernetes that allows you to control how clients (pods or other services) are directed to nodes having pods of a specific service. It enables you to specify rules that influence the scheduling of pods on nodes where pods of the selected service are placed.

Set Service Affinity Required#

As per this Service Affinity rule, the pods of the service is to be configured, will get scheduled only on the nodes having the pods of the selected service. In case, the nodes of the selected service can’t accommodate more pods, then scheduling will not take place.

For instance, if the chosen service is “Service A”, then all the pods will get scheduled only on the nodes where pods of Service A are placed. If there is no space in nodes of Service A, then scheduling of pods will not take place.

Here’s how you can set Set Service Affinity Required.

  • Click “Yes” to Set Service Affinity Required else click “No”.
  • Select a Service.

Docs Version Dropdown

Set Service Affinity Preferred#

As per this Service Affinity rule, the pods of the service that is to be configured, will prefer to get scheduled on the nodes having the pods of the selected service. In case, the nodes can’t accommodate more pods, then the pods will be scheduled on some other nodes.

For instance, if the chosen service is “Service A”, then all the pods will prefer to get scheduled on the nodes where pods of Service A are placed. If there is no space in nodes of Service A, then the pods will get scheduled on some other nodes.

Here’s how you can set Set Service Affinity Preferred.

  • Click “Yes” to Set Service Affinity Preferred else click “No”.
  • Select a Service.

Set Service Anti Affinity Required#

As per this Service Anti Affinity Rule, the pods of the service to be configured, will not get scheduled on the nodes where the pods of the selected service are placed. The service pods will get scheduled on any other node other than the node having the pods of the selected service.

For instance, let’s assume

  • New Service to be configured is Service A
  • Service chosen for Anti Service Affinity is Service B

Now, let’s see what will happen,

All pods of the Service A can be scheduled on any node other than the nodes where pods of Service B are placed. In case, there is no space in any other node, then too, the pods of Service A will not get scheduled on the nodes having pods of Service B. In such a scenario, no scheduling will take place.

Here’s how you can set Set Service Anti Affinity Required.

  • Click “Yes” to Set Service Anti Affinity Required else click “No”.
  • Select a Service.

Docs Version Dropdown

Set Service Anti Affinity Preferred#

As per this Service Anti Affinity Rule, the pods of the service to be configured, prefer to get scheduled on the nodes other than the nodes where the pods of the selected service are placed. But in case, there are no other nodes available that can accommodate the pods of the new service, then the pods will get scheduled on the node having the pods of the selected service.

For instance, let’s assume

  • New Service to be configured is Service A
  • Service chosen for Anti Service Affinity is Service B

Now, let’s see what will happen,

All pods of the Service A will prefer to get scheduled on nodes other than the nodes having pods of Service B. In case, there is no space in any other node, then the pods of Service A will get scheduled on the nodes having pods of Service B.

Here’s how you can set Set Service Anti Affinity Preferred.

  • Click “Yes” to Set Service Anti Affinity Preferred else click “No”.
  • Select a Service.